namespace NFreeMarker.Core
{
    /**
     * A template element where the content is ignored, a Comment.
     */
    public sealed class Comment : TemplateElement
    {
        private readonly string _text;

        internal Comment(string text)
        {
            _text = text;
        }

        internal override void Accept(Environment env)
        {
            // do nothing, skip the body
        }

        public override string GetCanonicalForm()
        {
            return "<#--" + _text + "-->";
        }

        public override string GetDescription()
        {
            string s = _text.Trim();
            if (s.Length > 20)
            {
                s = s.Substring(0, 20) + "...";
            }
            return "comment (" + s + ")";
        }

        public string GetText()
        {
            return _text;
        }
    }
}